package com.xh.fma.commodity.service.impl;


import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xh.common.utils.PageUtils;
import com.xh.common.utils.Query;

import com.xh.fma.commodity.dao.AttrAttrgroupRelationDao;
import com.xh.fma.commodity.entity.AttrAttrgroupRelationEntity;
import com.xh.fma.commodity.service.AttrAttrgroupRelationService;


@Service("attrAttrgroupRelationService")
public class AttrAttrgroupRelationServiceImpl extends ServiceImpl<AttrAttrgroupRelationDao, AttrAttrgroupRelationEntity> implements AttrAttrgroupRelationService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<AttrAttrgroupRelationEntity> page = this.page(
                new Query<AttrAttrgroupRelationEntity>().getPage(params),
                new QueryWrapper<>()
        );

        return new PageUtils(page);
    }

    @Override
    public void updateByAttrId(AttrAttrgroupRelationEntity entity) {
        this.update(entity, new UpdateWrapper<AttrAttrgroupRelationEntity>()
                .eq("attr_id",entity.getAttrId())
        );
    }

    @Override
    public void deleteBatchRelation(AttrAttrgroupRelationEntity[] entities) {
        this.baseMapper.deleteBatchByAttrAttrgroup(Arrays.asList(entities));
    }

}